package com.lotter.common.enumobject;

public enum ShengpingFuEnum {
	
	FAIL(0, "负"), TIED(1, "平"),VICTORY(3, "胜");
	
	private int code;

	private String desc;

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}


	public String getDesc() {
		return desc;
	}

	public void setDesc(String desc) {
		this.desc = desc;
	}

	private ShengpingFuEnum(int code,  String desc) {
		this.code = code;
		this.desc = desc;
	}
	
	public static String getDesc(int i){
		for (ShengpingFuEnum type : values()) {
			if(type.getCode()==i){
				return type.getDesc();
			}
		}
		return null;
	}
	
	
	public static Integer judgeCode(String scope){
		String[] arrayScore = scope.split(":");
		int home = Integer.parseInt(arrayScore[0]);
		int away = Integer.parseInt(arrayScore[1]);
		
		if(home > away){
			return ShengpingFuEnum.VICTORY.getCode();
		}else if(home == away){
			return ShengpingFuEnum.TIED.getCode();
		}else{
			return ShengpingFuEnum.FAIL.getCode();
		}
	}
	
	
	public static Integer judgeCode(String scope,Integer handicap){
		String[] arrayScore = scope.split(":");
		int home = Integer.parseInt(arrayScore[0]);
		int away = Integer.parseInt(arrayScore[1]);
		home +=handicap;
		if(home > away){
			return ShengpingFuEnum.VICTORY.getCode();
		}else if(home == away){
			return ShengpingFuEnum.TIED.getCode();
		}else{
			return ShengpingFuEnum.FAIL.getCode();
		}
	}

}
